package com.seu.vcampus.util;

import com.seu.vcampus.vo.User;

/**
 * 权限验证工具类
 * 用于检查用户是否有权限执行特定操作
 * 
 * @author 虚拟校园开发团队
 * @since 1.0.0
 */
public class PermissionUtil {
    
    /**
     * 检查用户是否有图书馆管理权限
     */
    public static boolean hasLibraryPermission(User.UserType userType) {
        return userType == User.UserType.ADMIN || 
               userType == User.UserType.LIBRARY_ADMIN;
    }
    
    /**
     * 检查用户是否有用户管理权限
     */
    public static boolean hasUserManagementPermission(User.UserType userType) {
        return userType == User.UserType.ADMIN || 
               userType == User.UserType.SYSTEM_ADMIN;
    }
    
    /**
     * 检查用户是否有系统管理权限
     */
    public static boolean hasSystemPermission(User.UserType userType) {
        return userType == User.UserType.ADMIN || 
               userType == User.UserType.SYSTEM_ADMIN;
    }
    
    /**
     * 检查用户是否有财务管理权限
     */
    public static boolean hasFinancePermission(User.UserType userType) {
        return userType == User.UserType.ADMIN || 
               userType == User.UserType.FINANCE_ADMIN;
    }
    
    /**
     * 检查用户是否有超级管理员权限
     */
    public static boolean hasSuperAdminPermission(User.UserType userType) {
        return userType == User.UserType.ADMIN;
    }
    
    /**
     * 获取用户权限描述
     */
    public static String getPermissionDescription(User.UserType userType) {
        if (userType == User.UserType.ADMIN) {
            return "拥有所有权限";
        } else if (userType == User.UserType.LIBRARY_ADMIN) {
            return "图书馆管理权限";
        } else if (userType == User.UserType.SYSTEM_ADMIN) {
            return "系统管理权限";
        } else if (userType == User.UserType.FINANCE_ADMIN) {
            return "财务管理权限";
        } else {
            return "普通用户权限";
        }
    }
}